package com.example.project.util;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class GenericityUtils {

    /**
     * Created with IntelliJ IDEA.
     * Description: 获取泛型实际类型
     */
    public static Class<?> getClass(Object o) throws ClassNotFoundException{

        ParameterizedType parameterizedType = (ParameterizedType) o.getClass().getGenericSuperclass();
        Type actualTypeArgument = parameterizedType.getActualTypeArguments()[0];

        return Class.forName(actualTypeArgument.getTypeName());
    }
}
